package com.mty.system.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.mty.common.entity.AclPermission;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author ：Teacher马（2508531326@qq.com）
 * @date ：Created in 2022/12/2 11:29
 * @description：
 * @modified By：
 * @version:
 */
public interface AclPermissionDao extends BaseMapper<AclPermission> {
    /**
     * 根据用户id查询权限信息
     * @return 不想写映射文件
     */
    @Select(value = "select p.* from acl_permission p join acl_role_permission rp on p.id=rp.permission_id " +
            "join acl_user_role ur on ur.role_id=rp.role_id where ur.user_id=#{userid}")
     List<AclPermission> selectByUserid(Long userid);

    @Select(value = "select p.* from acl_permission p join acl_role_permission rp on p.id=rp.permission_id "+
            "join acl_user_role ac on ac.role_id=rp.role_id "+
            "join acl_user ar on ar.id=ac.user_id where ar.username=#{username} AND type =1")
      List<AclPermission>  selectByUsername(String username);
}
